home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gdevdfax.c < prev    next >
C/C++ Source or Header  |  1993-05-20  |  25KB  |  763 lines

  1. /*
  2.  *    Copyright 1992 DigiBoard, Inc. All rights reserved
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and its
  5.  * documentation for any purpose and without fee is hereby granted.
  6.  * This software is provided "as is" without express or implied warranty.
  7.  */
  8. /*
  9.  * 5/19/93 modified by L. Peter Deutsch, Aladdin Enterprises,
  10.  *   for compatibility with Ghostscript 2.6.1.
  11.  */
  12.  
  13. /* gdevdfax.c */
  14. /* DigiBoard, Inc. DigiFAX driver for Ghostscript. */
  15.  
  16. #include "gdevprn.h"
  17. #include "gdevdfg3.h"
  18.  
  19. #ifdef __PROTOTYPES__
  20. #    define PROTO_ARGS(X)    X
  21. #else
  22. #    define PROTO_ARGS(X)    ()
  23. #endif
  24.  
  25. /*************************************************************************
  26.  *    Format of page header in PC Research "group_3" FAX file
  27.  *
  28.  *    Note that all "shorts" are stored LSB in lowest byte address
  29.  *************************************************************************/
  30. typedef struct
  31. {
  32.     char    magic[24];
  33. } FAXBREAK;
  34.  
  35. #define    FAXMAGIC    "\000PC Research, Inc\000\000\000\000\000\000"
  36.     
  37. typedef struct
  38. {
  39. /*24*/    short    pages;        /* Number of pages in file */
  40. /*26*/    short    pagenum;
  41. /*28*/    char    msbfirst;    /* Coding used in file for codewords */
  42.                 /* MUST be set to 1, meaning the codewords */
  43.                 /* are filled starting with the most */
  44.                 /* significant bit */
  45. /*29*/    char    hires;        /* Set to 1 for Hi resolution, else 0 */
  46. /*30*/    char    dirty;        /* File may contain T.4 errors if 1, else 0 */
  47.                 /* e.g. it was received by FAX, not created */
  48.                 /* by a program */
  49. /*31*/    char    reservedc;
  50. /*32*/    short    reserved[12];
  51. } FAXINFO;
  52.  
  53. #define    OFFSET_PAGES    24
  54.  
  55. typedef struct
  56. {
  57.     char    jt0;
  58.     char    jthires;    /* Set to 0x40 for Hi resolution, else 0 */
  59.     char    jt2;
  60.     char    jt3;
  61.     char    jt4;
  62.     char    jt5;
  63.     char    jt6;
  64.     char    jt7;
  65. } JTINFO;
  66.  
  67. /*
  68.  *    This appears before each page in a FAX file
  69.  */
  70. typedef struct
  71. {
  72.     FAXBREAK    id;
  73.     FAXINFO        info;
  74.     JTINFO        jtinfo;
  75. } FAXHDR;
  76.  
  77. /**********************************************************************/
  78. /*
  79.  *    Generic fax output library
  80.  */
  81. /**********************************************************************/
  82.  
  83. typedef struct
  84. {
  85.     FILE        *fp;
  86.     int        fax_byte;
  87.     int        fax_weight;
  88.     int        pages;
  89. } FAXOUT;
  90.  
  91. private FAXOUT    *faxout_open PROTO_ARGS((char *));
  92. private FAXOUT    *faxout_open_fp PROTO_ARGS((FILE *));
  93. private int    faxout_begin_page PROTO_ARGS((FAXOUT *, int));
  94. private int    faxout_eolcode PROTO_ARGS((FAXOUT *));
  95. private int    faxout_end_page PROTO_ARGS((FAXOUT *));
  96. private int    faxout_close PROTO_ARGS((FAXOUT *));
  97. private unsigned short fax_ushort PROTO_ARGS((unsigned short));
  98. private void    tofax();
  99.  
  100. private void putwhitespan();
  101. private void putblackspan();
  102. private void putcode();
  103. private void puteol();
  104. private void putbit();
  105. private void flushbits();
  106.  
  107. /*************************************************************************
  108.     Redefine the device descriptor
  109.  *************************************************************************/
  110. struct gx_device_dfax_s {
  111.     gx_device_common;
  112.     gx_prn_device_common;
  113.     FAXOUT    *fax;
  114. };
  115. typedef struct gx_device_dfax_s gx_device_dfax;
  116.  
  117. /* The device descriptor */
  118. #define X_DPI 204
  119. #define Y_DPI 196
  120. #define LINE_SIZE ((X_DPI * 85 / 10 + 7) / 8)    /* bytes per line */
  121.  
  122. private dev_proc_open_device(dfax_prn_open);
  123. private dev_proc_print_page(dfax_print_page);
  124. private dev_proc_close_device(dfax_prn_close);
  125.  
  126. gx_device_procs dfax_std_procs =
  127.     prn_procs(dfax_prn_open, gdev_prn_output_page, dfax_prn_close);
  128.  
  129. gx_device_dfax gs_dfaxhigh_device =
  130. {    prn_device_std_body(
  131.         gx_device_dfax,
  132.         dfax_std_procs,
  133.         "dfaxhigh",
  134.         85,            /* width_10ths, 8.5" */
  135.         110,            /* height_10ths, 11" */
  136.         X_DPI, Y_DPI,
  137.         0,0,0,0,        /* margins */
  138.         1,
  139.         dfax_print_page
  140.     )
  141. };
  142.  
  143. gx_device_dfax gs_dfaxlow_device =
  144. {    prn_device_std_body(
  145.         gx_device_dfax,
  146.         dfax_std_procs,
  147.         "dfaxlow",
  148.         85,            /* width_10ths, 8.5" */
  149.         110,            /* height_10ths, 11" */
  150.         X_DPI, Y_DPI/2,
  151.         0,0,0,0,        /* margins */
  152.         1,
  153.         dfax_print_page
  154.     )
  155. };
  156.  
  157. /*************************************************************************
  158.     Driver entry points
  159.  *************************************************************************/
  160.  
  161. private int
  162. dfax_prn_open(gx_device *pdev)
  163. {
  164.     gx_device_dfax    *ddev = (gx_device_dfax *) pdev;
  165.     int        rc;
  166.  
  167.     rc = gdev_prn_open(pdev);
  168.     ddev->fax = faxout_open_fp(ddev->file);
  169.     return (rc);
  170. }
  171.  
  172. private int
  173. dfax_print_page(gx_device_printer *pdev, FILE *prn_stream)
  174. {
  175.     gx_device_dfax    *ddev = (gx_device_dfax *) pdev;
  176.     char        data[LINE_SIZE + 4];
  177.     int        lnum;
  178.     int        line_size;
  179.     FAXOUT        *fax = ddev->fax;
  180.  
  181.     /* For some odd reason, the file isn't open until now */
  182.     fax->fp = prn_stream;    
  183.     faxout_begin_page(fax, ddev->y_pixels_per_inch > 120);
  184.     
  185.     line_size = gdev_mem_bytes_per_scan_line( (gx_device *) pdev);
  186.     for ( lnum = 0; lnum < pdev->height; lnum++ )
  187.     {
  188.         gdev_prn_copy_scan_lines(pdev, lnum, (byte *)data, line_size);
  189.         tofax(fax, data, 1728);
  190.     }
  191.     faxout_end_page(fax);
  192.     return 0;
  193. }
  194.  
  195. private int
  196. dfax_prn_close(gx_device *pdev)
  197. {
  198.     gx_device_dfax    *ddev = (gx_device_dfax *) pdev;
  199.     int        rc;
  200.     FAXOUT        *fax = ddev->fax;
  201.     unsigned short     p = fax_ushort(fax->pages);
  202.  
  203.     if (fax->fp)
  204.     {
  205.         fflush(fax->fp);
  206.         if (fseek(fax->fp, (long) OFFSET_PAGES, 0) == 0)
  207.             fwrite((char*)&p, sizeof(p), 1, fax->fp);
  208.     }
  209.     rc = gdev_prn_close(pdev);
  210.     return(rc);
  211. }
  212.  
  213. /*************************************************************************
  214.     Internal routines
  215.  *************************************************************************/
  216.  
  217. /************************Coding FAX Routines*************************/
  218. /*
  219.  *    faxp = faxout_open(filename);
  220.  *    faxp = faxout_open_fp(fp);
  221.  *    faxout_begin_page(faxp, resolution);
  222.  *    for(;;) tofax(faxp, linebuf);
  223.  *    faxout_end_page(faxp);
  224.  *    faxout_close(faxp);
  225.  */
  226.  
  227. private FAXOUT    *
  228. faxout_open_fp(FILE *fp)
  229. {
  230.     register FAXOUT    *faxp;
  231.  
  232.     faxp = (FAXOUT *) malloc(sizeof(*faxp));
  233.  
  234.     faxp->fp = fp;
  235.     faxp->fax_byte = 0;
  236.     faxp->fax_weight = 0x80;
  237.     faxp->pages = 0;
  238.  
  239.     return (faxp);
  240. }
  241.  
  242. private FAXOUT    *
  243. faxout_open(char *filename)
  244. {
  245.     register FILE    *fp;
  246.     register FAXOUT    *faxp;
  247.  
  248.     if (filename)
  249.         fp = fopen(filename, "wb");
  250.     else
  251.         fp = stdout;
  252.     if (!fp) return (NULL);
  253.  
  254.     return(faxout_open_fp(fp));
  255. }
  256.  
  257. private int
  258. faxout_begin_page(FAXOUT *faxp, int resolution)
  259. {
  260.     FAXHDR    hdr;
  261.  
  262.     memset(&hdr, 0, sizeof(hdr));
  263.     memcpy(hdr.id.magic, FAXMAGIC, sizeof(hdr.id.magic));
  264.     hdr.info.pagenum = fax_ushort(++faxp->pages);
  265.     hdr.info.msbfirst = 1;
  266.     hdr.info.hires = resolution;
  267.     hdr.jtinfo.jthires = resolution ? 0x40 : 0;
  268.     fwrite((char*)&hdr, sizeof(hdr), 1, faxp->fp);
  269.  
  270.     puteol(faxp);
  271.  
  272.     return (0);
  273. }
  274.  
  275. private int
  276. faxout_end_page(FAXOUT *faxp)
  277. {
  278.     flushbits(faxp);
  279.     puteol(faxp);
  280.     puteol(faxp);
  281.     puteol(faxp);
  282.     puteol(faxp);
  283.     puteol(faxp);
  284.     flushbits(faxp);
  285.     return (0);
  286. }
  287.  
  288. private int
  289. faxout_close(FAXOUT *faxp)
  290. {
  291.     unsigned short p = fax_ushort(faxp->pages);
  292.  
  293.     fflush(faxp->fp);
  294.     if (fseek(faxp->fp, (long) OFFSET_PAGES, 0) == 0)
  295.         fwrite((char*)&p, sizeof(p), 1, faxp->fp);
  296.     fclose(faxp->fp);
  297.     free(faxp);
  298.  
  299.     return (0);
  300. }
  301.  
  302. private unsigned short
  303. fax_ushort(unsigned short v)
  304. {
  305.     static unsigned short    x = 0x1122;
  306.     static unsigned short    *xp = &x;
  307.     
  308.     if ( *((unsigned char *)xp) == 0x22)
  309.         return (v);
  310.     else
  311.         return ( ((v>>8)&255) + (v<<8) );
  312. }
  313.  
  314. private unsigned char    b_run_tbl[8][256] =
  315. {
  316.   {    /* START BIT 0 */
  317.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  318.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  319.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  320.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  321.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  322.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  323.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  324.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  325.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  326.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  327.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  328.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  329.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  330.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  331.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  332.     0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
  333.   },
  334.   {    /* START BIT 1 */
  335.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  336.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  337.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  338.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  339.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  340.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  341.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  342.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  343.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  344.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  345.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  346.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  347.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  348.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  349.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  350.     0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 
  351.   },
  352.   {    /* START BIT 2 */
  353.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  354.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  355.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  356.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  357.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  358.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  359.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  360.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  361.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  362.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  363.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  364.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  365.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  366.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  367.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  368.     0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 1, 1, 2, 3, 
  369.   },
  370.   {    /* START BIT 3 */
  371.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  372.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  373.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  374.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  375.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  376.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  377.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  378.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  379.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  380.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  381.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  382.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  383.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  384.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  385.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  386.     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4, 
  387.   },
  388.   {    /* START BIT 4 */
  389.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  390.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  391.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  392.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  393.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  394.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  395.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  396.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  397.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  398.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  399.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  400.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  401.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  402.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  403.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  404.     1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 
  405.   },
  406.   {    /* START BIT 5 */
  407.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  408.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  409.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  410.     2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, 
  411.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  412.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  413.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  414.     2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, 
  415.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  416.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  417.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  418.     2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, 
  419.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  420.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  421.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  422.     2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, 
  423.   },
  424.   {    /* START BIT 6 */
  425.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  426.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  427.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  428.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  429.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  430.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  431.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  432.     3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7, 
  433.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  434.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  435.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  436.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  437.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  438.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  439.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  440.     3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7, 
  441.   },
  442.   {    /* START BIT 7 */
  443.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  444.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  445.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  446.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  447.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  448.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  449.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  450.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  451.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  452.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  453.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  454.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  455.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  456.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  457.     3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
  458.     4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, 
  459.   },
  460. };
  461.  
  462. private unsigned char    w_run_tbl[8][256] =
  463. {
  464.   {    /* START BIT 0 */
  465.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  466.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  467.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  468.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  469.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  470.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  471.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  472.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  473.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  474.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  475.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  476.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  477.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  478.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  479.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  480.     1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 
  481.   },
  482.   {    /* START BIT 1 */
  483.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  484.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  485.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  486.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  487.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  488.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  489.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  490.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  491.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  492.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  493.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  494.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  495.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  496.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  497.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  498.     2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 
  499.   },
  500.   {    /* START BIT 2 */
  501.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  502.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  503.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  504.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  505.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  506.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  507.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  508.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  509.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  510.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  511.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  512.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  513.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  514.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  515.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  516.     3, 2, 1, 1, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 
  517.   },
  518.   {    /* START BIT 3 */
  519.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  520.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  521.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  522.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  523.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  524.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  525.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  526.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  527.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  528.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  529.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  530.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  531.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  532.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  533.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  534.     4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
  535.   },
  536.   {    /* START BIT 4 */
  537.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  538.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  539.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  540.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  541.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  542.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  543.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  544.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  545.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  546.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  547.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  548.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  549.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  550.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  551.     5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 
  552.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  553.   },
  554.   {    /* START BIT 5 */
  555.     6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 
  556.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  557.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  558.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  559.     6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 
  560.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  561.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  562.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  563.     6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 
  564.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  565.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  566.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  567.     6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 
  568.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  569.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  570.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  571.   },
  572.   {    /* START BIT 6 */
  573.     7, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 
  574.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  575.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  576.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  577.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  578.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  579.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  580.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  581.     7, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 
  582.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  583.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  584.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  585.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  586.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  587.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  588.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  589.   },
  590.   {    /* START BIT 7 */
  591.     8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 
  592.     3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
  593.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  594.     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  595.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  596.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  597.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  598.     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  599.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  600.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  601.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  602.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  603.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  604.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  605.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  606.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  607.   },
  608. };
  609.  
  610. /*
  611.  *    Macros to use tables in findrun.c
  612.  *    Input is *p, bit
  613.  *    Output is rl, *p, bit
  614.  */
  615.  
  616. #define    find_black_run() \
  617. for (rl = 0;;) \
  618. { \
  619.     if (run = b_run_tbl[bit][*p]) \
  620.     { \
  621.         rl += run; \
  622.         bit -= run; \
  623.         if (bit < 0 && ++p < ep) { bit=7; continue;} \
  624.     } \
  625.     break; \
  626. }
  627.  
  628. #define    find_white_run() \
  629. for (rl = 0;;) \
  630. { \
  631.     if (run = w_run_tbl[bit][*p]) \
  632.     { \
  633.         rl += run; \
  634.         bit -= run; \
  635.         if (bit < 0 && ++p < ep) { bit=7; continue;} \
  636.     } \
  637.     break; \
  638. }
  639.  
  640. private void
  641. tofax(FAXOUT *faxp, unsigned char *p)
  642. {
  643.     unsigned char        *ep;
  644.     register int        bit;
  645.     register int        run;
  646.     register int        rl;
  647.  
  648.     ep = p + 1728/8;
  649.     bit = 7;
  650.     for (;;)
  651.     {
  652.         find_white_run();
  653.         putwhitespan(faxp, rl);
  654.         if (p >= ep) break;
  655.  
  656.         find_black_run();
  657.         putblackspan(faxp, rl);
  658.         if (p >= ep) break;
  659.     }
  660.     puteol(faxp);
  661. }
  662.  
  663.  
  664. /*************************************************************************
  665.     The rest of this file is a FAX encoding algorithm
  666.     derived from pbmplus.  It is not the normal DigiFAX algorithm.
  667.     The following copyright applies.
  668. **
  669. ** Copyright (C) 1989 by Paul Haeberli <paul@manray.sgi.com>.
  670. **
  671. ** Permission to use, copy, modify, and distribute this software and its
  672. ** documentation for any purpose and without fee is hereby granted, provided
  673. ** that the above copyright notice appear in all copies and that both that
  674. ** copyright notice and this permission notice appear in supporting
  675. ** documentation.  This software is provided "as is" without express or
  676. ** implied warranty.
  677.  *************************************************************************/
  678.  
  679. private void
  680. putwhitespan(register FAXOUT *faxp, int c)
  681. {
  682.     register int tpos;
  683.     register tableentry* te;
  684.  
  685.     if(c>=64) {
  686.     tpos = (c/64)-1;
  687.     te = mwtable+tpos;
  688.     c -= te->count;
  689.     putcode(faxp, te);
  690.     }
  691.     tpos = c;
  692.     te = twtable+tpos;
  693.     putcode(faxp, te);
  694. }
  695.  
  696. private void
  697. putblackspan(register FAXOUT *faxp, int c)
  698. {
  699.     register int tpos;
  700.     register tableentry* te;
  701.  
  702.     if(c>=64) {
  703.     tpos = (c/64)-1;
  704.     te = mbtable+tpos;
  705.     c -= te->count;
  706.     putcode(faxp, te);
  707.     }
  708.     tpos = c;
  709.     te = tbtable+tpos;
  710.     putcode(faxp, te);
  711. }
  712.  
  713. private void
  714. putcode(register FAXOUT *faxp, tableentry *te)
  715. {
  716.     register unsigned int mask;
  717.     register int code;
  718.  
  719.     mask = 1<<(te->length-1);
  720.     code = te->code;
  721.     while(mask) {
  722.      if(code&mask)
  723.         putbit(faxp, 1);
  724.     else
  725.         putbit(faxp, 0);
  726.     mask >>= 1;
  727.     }
  728.  
  729. }
  730.  
  731. private void
  732. puteol(register FAXOUT *faxp)
  733. {
  734.     register int i;
  735.  
  736.     for(i=0; i<11; ++i)
  737.     putbit(faxp, 0);
  738.     putbit(faxp, 1);
  739. }
  740.  
  741. private void
  742. putbit(register FAXOUT *faxp, int d)
  743. {
  744.     if(d) 
  745.     faxp->fax_byte = faxp->fax_byte|faxp->fax_weight;
  746.     faxp->fax_weight = faxp->fax_weight>>1;
  747.     if((faxp->fax_weight&0xff) == 0) {
  748.     putc(faxp->fax_byte, faxp->fp);
  749.     faxp->fax_byte = 0;
  750.     faxp->fax_weight = 0x80;
  751.     }
  752. }
  753.  
  754. private void
  755. flushbits(register FAXOUT *faxp)
  756. {
  757.     if (faxp->fax_weight != 0x80) {
  758.     putc(faxp->fax_byte, faxp->fp);
  759.     faxp->fax_byte = 0;
  760.     faxp->fax_weight = 0x80;
  761.     }
  762. }
  763.